Background and Foreground Subtraction

In this lesson we'll learn:

  1. Background Subtraction with Gaussian Mixture-based Background/Foreground Segmentation Algorithm
  2. Improved adaptive Gausian mixture model for background subtraction

Taken fron the OpenCV Docs

Background subtraction (BS) is a common and widely used technique for generating a foreground mask (namely, a binary image containing the pixels belonging to moving objects in the scene) by using static cameras.

As the name suggests, BS calculates the foreground mask performing a subtraction between the current frame and a background model, containing the static part of the scene or, more in general, everything that can be considered as background given the characteristics of the observed scene.

Background modeling consists of two main steps:

  1. Background Initialization;
  2. Background Update.

In the first step, an initial model of the background is computed, while in the second step that model is updated in order to adapt to possible changes in the scene.

Uzbekcha

Fonni ayirish (BS) statik kameralar yordamida oldingi fon niqobini (masalan, sahnadagi harakatlanuvchi ob'ektlarga tegishli piksellarni o'z ichiga olgan ikkilik tasvir) yaratish uchun keng tarqalgan va keng qo'llaniladigan usuldir.

Nomidan ko'rinib turibdiki, BS sahnaning statik qismini yoki umuman olganda, kuzatilayotgan sahnaning xususiyatlarini hisobga olgan holda fon sifatida ko'rib chiqilishi mumkin bo'lgan barcha narsalarni o'z ichiga olgan joriy ramka va fon modeli o'rtasida ayirishni amalga oshiruvchi oldingi fon niqobini hisoblab chiqadi.

Fonni modellashtirish ikki asosiy bosqichdan iborat:

  1. Fonni ishga tushirish;
  2. Fonni yangilash.

Birinchi bosqichda fonning dastlabki modeli hisoblab chiqiladi, ikkinchi bosqichda esa bu model sahnadagi mumkin bo'lgan o'zgarishlarga moslashish uchun yangilanadi.

What is Background Subtraction?

Background subtraction is a computer vision technique where we seek to isolate the background from the 'moving' foreground. Consider vehciles traversing a roadway, or persons walking along a sidewalk.

It sounds simple in theory (i.e. just keep the station pixels and remove the ones that were changing). However, things like lighting condition changes, shadows etc. can make things get more complicated.

Several algorithms were introduced for this purpose. In the following, we will have a look at two algorithms from the bgsegm module.

Uzbekcha

Fonni ayirma - bu kompyuterni ko'rish usuli bo'lib, biz fonni "harakatlanuvchi" oldingi plandan ajratishga harakat qilamiz. Yo'ldan o'tayotgan transport vositalarini yoki piyodalar yo'lakchasi bo'ylab ketayotgan odamlarni ko'rib chiqing.

Nazariy jihatdan oddiy ko'rinadi (ya'ni, faqat stantsiya piksellarini saqlang va o'zgaruvchanlarini olib tashlang). Biroq, yorug'lik holatining o'zgarishi, soyalar va boshqalar kabi narsalarni murakkablashtirishi mumkin.

Shu maqsadda bir nechta algoritmlar kiritilgan. Quyida biz bgsegm modulidan ikkita algoritmni ko'rib chiqamiz.

1-usul. Gaussian Mixture-based Background/Foreground Segmentation Algorithm

In this paper, we propose a background subtraction (BGS) method based on the Gaussian mixture models using color and depth information. For combining color and depth information, we used the probabilistic model based on Gaussian distribution. In particular, we focused on solving color camouflage problem and depth denoising. For evaluating our method, we built a new dataset containing normal, color camouflage and depth camouflage situations. The dataset files consist of color, depth and ground truth image sequences. With these files, we compared the proposed algorithm with the conventional color-based BGS techniques in terms of precision, recall and F-measure. As a result, our method showed the best performance. Thus, this technique will help to robustly detect regions of interest as pre-processing in high-level image processing stages.

Link to Paper - https://www.researchgate.net/publication/283026260_Background_subtraction_based_on_Gaussian_mixture_models_using_color_and_depth_information

Uzbekcha

Ushbu maqolada biz rang va chuqurlik ma'lumotlaridan foydalangan holda Gauss aralashmasi modellariga asoslangan fonni olib tashlash (BGS) usulini taklif qilamiz. Rang va chuqurlik ma'lumotlarini birlashtirish uchun biz Gauss taqsimotiga asoslangan ehtimollik modelidan foydalandik. Xususan, biz ranglarni kamuflyaj muammosini va chuqurlikni yo'qotish muammosini hal qilishga e'tibor qaratdik. Bizning usulimizni baholash uchun biz oddiy, rangli kamuflyaj va chuqurlikdagi kamuflyaj holatlarini o'z ichiga olgan yangi ma'lumotlar to'plamini yaratdik. Ma'lumotlar to'plami fayllari rang, chuqurlik va asosiy haqiqat tasvirlari ketma-ketliklaridan iborat. Ushbu fayllar yordamida biz taklif qilingan algoritmni an'anaviy rangga asoslangan BGS texnikasi bilan aniqlik, eslab qolish va F o'lchovi nuqtai nazaridan solishtirdik. Natijada, bizning usulimiz eng yaxshi ko'rsatkichni ko'rsatdi. Shunday qilib, ushbu uslub yuqori darajadagi tasvirni qayta ishlash bosqichlarida oldindan ishlov berish sifatida qiziqish hududlarini ishonchli aniqlashga yordam beradi.

2-usul. Improved adaptive Gausian mixture model for background subtraction

Background subtraction is a common computer vision task. We analyze the usual pixel-level approach. We develop an efficient adaptive algorithm using Gaussian mixture probability density. Recursive equations are used to constantly update the parameters and but also to simultaneously select the appropriate number of components for each pixel.

https://www.researchgate.net/publication/4090386_Improved_Adaptive_Gaussian_Mixture_Model_for_Background_Subtraction

Orqa fonni olib tashlash - bu kompyuterni ko'rishning keng tarqalgan vazifasi. Biz odatdagi piksel darajasidagi yondashuvni tahlil qilamiz. Biz Gauss aralashmasi ehtimoli zichligidan foydalangan holda samarali adaptiv algoritmni ishlab chiqamiz. Rekursiv tenglamalar parametrlarni doimiy ravishda yangilash uchun, shuningdek, bir vaqtning o'zida har bir piksel uchun mos keladigan komponentlar sonini tanlash uchun ishlatiladi.

Bitwise yordamida foregroundni yaxshiroq korish

3-usul. Background Substraction KKN

The parameters if you wish to veer away from the default settings:

https://docs.opencv.org/master/de/de1/group__video__motion.html#gac9be925771f805b6fdb614ec2292006d

Foreground Subtraction